package com.atguigu.spring.pojo;

public class teacher {
    private Integer tid;
    private String tname;

    public teacher(Integer tid, String tname) {
        this.tid = tid;
        this.tname = tname;
    }

    public teacher() {
        //通过反射+工厂模式创建对象，通过反射获取Class类型实例，
        //通过该class实例调用无参构造方法创建一个对象
        System.out.println("生命周期1——实例化创建对象");
    }

    public Integer getTid() {
        return tid;
    }

    public void setTid(Integer tid) {
        System.out.println("生命周期2——依赖注入为属性赋值");
        this.tid = tid;
    }

    public String getTname() {
        return tname;
    }

    public void setTname(String tname) {
        this.tname = tname;
    }

    @Override
    public String toString() {
        return "teacher{" +
                "tid=" + tid +
                ", tname='" + tname + '\'' +
                '}';
    }

    public void initMethod(){
        System.out.println("生命周期3——初始化");
    }

    public void destroyMethod(){
        System.out.println("生命周期4——销毁");
    }
}
